
package com.android.test.activity;

import com.android.test.R;

import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.util.Log;

public class MenuSettingActivity extends PreferenceActivity {
    private static final String page = "MenuSetting";

    @Override
    public void onCreate(Bundle savedInstanceState) {

        if (PreferenceManager.getDefaultSharedPreferences(MenuSettingActivity.this).getBoolean(
                "checkbox_screen_lock", false)) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
        }

        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.setting_preferences);

    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();

    }

    @Override
    public boolean onSearchRequested() {
        return false;
    }

    @Override
    public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
        if (PreferenceManager.getDefaultSharedPreferences(MenuSettingActivity.this).getBoolean(
                "checkbox_screen_lock", false)) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
        }
        return super.onPreferenceTreeClick(preferenceScreen, preference);
    }

}
